package com.penghaisoft.microwms.material.web.outwarehouse.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.common.data.model.RawRequisition;
import com.penghaisoft.microwms.common.data.model.RawRequisitionSn;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.material.web.outwarehouse.dao.OutWhRawMapper;
import com.penghaisoft.microwms.material.web.outwarehouse.dao.RawRequisitionSnMapper;
import com.penghaisoft.microwms.material.web.outwarehouse.service.OutWhRawService;

/**
 * Created by 王治国 on 2018/5/18.
 */
@Service
public class OutWhRawServiceImpl extends BaseService implements OutWhRawService {

    @Autowired
    private OutWhRawMapper outWhRawMapper;
    
    @Autowired
    private RawRequisitionSnMapper rawRequisitionSnMapper;


    @Override
    public Pager<RawRequisition> findAll(int page, int rows, RawRequisition rawRequisition) {
        long size = outWhRawMapper.queryCount(rawRequisition);
        Pager<RawRequisition> pager = new Pager<>();
        List<RawRequisition> result = new ArrayList<>();
        pager.setPage(page);
        pager.setRows(rows);
        if (size > 0) {
            result = outWhRawMapper.queryList(pager, rawRequisition);
        }
        pager.setRecords(result);
        pager.setTotalCount(size);
        return pager;
    }
    
    /** 
     * @Title findList
     * @Description 根据领料单号查询数据
     * @author luoteng
     * @date 2018年7月3日:下午4:32:02
     * @param rawRequisition
     * @return TransResult
     */
    @Override
    public List<RawRequisition> findList(RawRequisition rawRequisition) {
        return outWhRawMapper.queryList(null, rawRequisition);
    }

    @Override
    public List<RawRequisition> findAllExcel(RawRequisition rawRequisition) {
        return null;
    }
    
    @Override
    public Pager<RawRequisitionSn> findListByRequestionNo(int page, int rows, RawRequisitionSn rawRequisitionSn){
    	long size = rawRequisitionSnMapper.queryCount(rawRequisitionSn);
        Pager<RawRequisitionSn> pager = new Pager<>();
        List<RawRequisitionSn> result = new ArrayList<>();
        pager.setPage(page);
        pager.setRows(rows);
        if (size > 0) {
            result = rawRequisitionSnMapper.queryList(pager, rawRequisitionSn);
        }
        pager.setRecords(result);
        pager.setTotalCount(size);
        return pager;
    }
}
